home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 5.4 KB | 247 lines | [TEXT/CWIE] |
- /*
-
- File: SprocketNothing.cp
- Project: Sample code for Sprocket Framework 1.1 (DR2), released 6/15/96
- Contains: Boilerplate application-specific code
- To Do: Whatever your heart desires
-
- Sprocket Major Contributors:
- ----------------------------
- Dave Falkenburg, producer of Sprocket 1.0
- Bill Hayden, producer of Sprocket 1.1
- Steve Sisak, producer of the upcoming Sprocket 2.0
-
- Pete Alexander Steve Falkenburg Randy Thelen
- Eric Berdahl Nitin Ganatra Chris K. Thomas
- Marshall Clow Dave Hershey Leonard Rosenthal
- Tim Craycroft Dave Mark Dean Yu
- David denBoer Gary Powell
- Cameron Esfahani Jon Summers Apple Computer, Inc.
-
- Comments, Additions, or Corrections:
- ------------------------------------
- Bill Hayden, Nikol Software <nikol@codewell.com>
-
- */
-
-
-
- #include "Sprocket.h"
- #include "UDialog.h"
- #include "SplashWindow.h"
-
- #include "EmptyWindow.h"
-
- // Function Prototypes:
-
- void AboutBox(void);
- void OpenExistingDocument(void);
-
- #define kAboutBoxFor68K 256
- #define kAboutBoxForPowerPC 257
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // SetupApplication
- //
- // Modify this function to provide any application-specific
- // initialization you may require.
- //
- // This is a good place to call EnterMovies, allocate
- // sound channels, setup network things, etc.
- //
- // For kicks, I am sercuring this application with Serial Number protection
-
- OSErr SetupApplication(void)
- {
- InitCursor();
-
- return noErr;
- }
-
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // TearDownApplication
- //
- // Modify this function to tear down anything that you allocated
- // from within SetupApplication.
-
- void TearDownApplication(void)
- {
- }
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // HandleMenuCommand
- //
- // Modify this function to handle any registered menu commands
- // that aren’t specific to a particular window.
-
- void HandleCommand(CommandID theCommand)
- {
- switch (theCommand)
- {
- case cAbout:
- AboutBox();
- break;
-
- case cNew:
- CreateNewDocument();
- break;
-
- case cOpen:
- OpenExistingDocument();
- break;
-
- default:
- break;
- }
- }
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // HandleMenuSelection
- //
- // Modify this function to handle any menu selections that aren’t
- // specific to a particular window. Normally, you shouldn’t need to
- // do anything, unless you hate using MenuCommands.
-
- void HandleMenuSelection(MenuID /* theMenu */, MenuItemID /* theItem */)
- {
- }
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // ReadLocalClipboardFromScrap & WriteLocalClipboardToScrap
- //
- // These functions will be called whenever the user switches into
- // or out of your application.
- //
- // If you keep copy of the clipboard in your own data structures,
- // these functions will allow you to keep it in synch so that the
- // user can cut and paste information between your program and
- // other applications.
- //
- // We don’t actually use the clipboard in SprocketSample, so these
- // functions are empty for now.
-
- void ReadLocalClipboardFromScrap(void)
- {
- }
-
- void WriteLocalClipboardToScrap(void)
- {
- }
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // CreateNewDocument, OpenDocument, PrintDocument, and
- // QuitApplication.
- //
- // These functions will be called whenever one of the required
- // AppleEvents is sent to your application— either when your
- // program is launched, or when the user opens a document from
- // the Finder.
-
- OSErr CreateNewDocument(void)
- {
- TEmptyWindow* aWindow = new TEmptyWindow;
-
- if (aWindow == nil)
- return nilHandleErr;
- else
- return noErr;
- }
-
-
- OSErr OpenDocument(FSSpec* theDocument, void * /*unused*/)
- {
- // A normal app would open the document passed to this function
- // This shell just opens a new document.
-
- return CreateNewDocument();
- }
-
-
- OSErr PrintDocument(FSSpec* /* theDocument */, void * /*unused*/)
- {
- // We don’t do printing yet, but you could.
- return errAEEventNotHandled;
- }
-
-
- Boolean QuitApplication(void)
- {
- // Just go ahead and say we’re done quitting…
- // We have no app-specific clean-up or chores to do here, but you might.
-
- return true;
- }
-
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // AboutBox
- //
- // Put up our about box, including the version number. Depending
- // on what version we are running, pick the correct DLOG resource.
- //
-
- void AboutBox(void)
- {
- Handle versionHandle;
- StringPtr shortVersionString;
- short itemHit;
-
-
- versionHandle = GetResource('vers', 1);
- if (versionHandle)
- {
- shortVersionString = (StringPtr) ((char *) *versionHandle + 6);
- ParamText(shortVersionString, "\p", "\p", "\p");
- ReleaseResource(versionHandle);
- }
-
- #if GENERATING68K
- itemHit = StandardAlert(kAboutBoxFor68K);
- #else
- itemHit = StandardAlert(kAboutBoxForPowerPC);
- #endif
- }
-
-
-
- ////////////////////////////////////////////////////////////////////
- //
- // OpenExistingDocument
- //
- // Use StandardFile to ask the user for a file to open. We use
- // CustomGetFile so that we can properly handle update events
- // in other windows while the dialog is active.
-
- void OpenExistingDocument(void)
- {
- StandardFileReply reply;
- SFTypeList ourTypes;
-
- Point where = { -1, -1 };
-
- HiliteWindowsForModalDialog(false);
- CustomGetFile((FileFilterYDUPP) nil, -1, ourTypes, &reply, 0, where,
- (DlgHookYDUPP) nil, StandardDialogFilterYDUPP, nil, nil, nil);
- HiliteWindowsForModalDialog(true);
-
- if (reply.sfGood)
- {
- OpenDocument(&reply.sfFile, nil);
- }
- }
-